import 'package:flutter/material.dart';
import '../../Model/post.dart';

class classDemo extends StatelessWidget {
  const classDemo({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      
    );
  }
}

class SliverDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CustomScrollView(
      slivers: <Widget>[
        SliverAppBarDemo(),
        SliverSafeArea(
          sliver: SliverPadding(
            padding: EdgeInsets.all(8.0),
            sliver: SliverListDemo(),
          )
        ),
      ],
    );
  }
}

class SliverAppBarDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SliverAppBar(
      title: Text('Xuyc'),
      // pinned: true,
      floating: true,
      expandedHeight: 178.0,
      flexibleSpace: FlexibleSpaceBar(
        title: Text(
          'wxh love xyc'.toUpperCase(),
          style: TextStyle(
            fontSize: 15.0,
            letterSpacing: 3.0,
            fontWeight: FontWeight.bold
          )
        ),
        background: Image.network(
          'http://deepexiobs.ghub.cn/08779230-0919-497e-a9f0-897939ff580e.jpg',
          fit: BoxFit.cover,
          colorBlendMode: BlendMode.colorBurn,
        ),
      ),
    );
  }
}

class SliverListDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SliverList(
      delegate: SliverChildBuilderDelegate (
        (BuildContext context, int index){
          return Container(
            margin: EdgeInsets.only(top:10),
            child: Image.network(
              posts[index].imageUrl,
              fit: BoxFit.cover
            ),
          );
        },
        childCount: posts.length,
      )
    );
  }
}

class SliverGridDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SliverGrid(
      delegate: SliverChildBuilderDelegate(
        (BuildContext context, int index){
          return Container(
            child: Image.network(
              posts[index].imageUrl,
              fit: BoxFit.cover
            ),
          );
        },
        childCount: posts.length,
      ), 
      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 2,
        crossAxisSpacing: 10.0,
        mainAxisSpacing: 10.0,
        childAspectRatio: 0.8
      )
    );
  }
}